/*
 *  DOWANT.h
 *  TubeTruck
 *
 *  Created by Aeturnum on 6/4/08.
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
 *
 */

#include <vector>
#include <assert.h>
#include <exception>

#include "TubeTruckTypes.h"
#include "serialization.h"
#include "unserialization.h" 
#include "smartalloc_wrap.h"
#include "Signable.h"
#include "Signiture.h"
#include "Encryptable.h"
#include "RSA.h"
#include "util.h"

namespace TTP  {
   class DOWANT : public Packet, public Crypt::Signable, public Crypt::Encryptable {
   protected:
      std::vector<byte> mSymKey, mGroupPrivateKey;
      
      void fillEncryptedSection();
      
   public:
      DOWANT();
      DOWANT(id_hash);
      DOWANT(id_hash, std::vector<byte>&, std::vector<byte>&, std::vector<byte>&);
      ~DOWANT();
      
      // accessor
      std::vector<byte> getGroupSig() const;
      std::vector<byte> getSymmetricKey() const;
      std::vector<byte> getGroupPrivateKey() const;
      
      void setGroupSig(Crypt::Signiture);
      void setSymmetricKey(std::vector<byte>&);
      void setGroupPrivateKey(std::vector<byte>&);
      
      // idHash
      void  setDestIdHash(id_hash);
      id_hash getDestIdHash() const;
      
      //inherited
      void fromVec(std::vector<byte>::const_iterator &vit, std::vector<byte>::const_iterator &end);
      void toVec(std::vector<byte> &vec) const;
      
      
      void setEncryptedData(std::vector<byte>&);
      void setPlainText(std::vector<byte>&);
      std::vector<byte> getEncryptedSection();
      
      std::vector<byte> getUnsignedData() const;
   };
}
